package com.eternalrights.other;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class test {
    public static void main(String[] args) {
        //目标：认识Stream流，掌握其基本使用步骤。
        List<String> list = new ArrayList<>();
        list.add("张无忌");
        list.add("周芷若");
        list.add("赵敏");
        list.add("张强");
        list.add("张三丰");

        list.stream().filter(name->name.startsWith("张")).filter(name->name.length()==3).toList().forEach(System.out::println);

        Stream<String> s = list.stream().filter(name->name.startsWith("张"));

        List<String> lst = s.collect(Collectors.toList());
    }

    public static void sum(int...sum){
        int result = 0;
        for (int i : sum) {
            result += i;
        }
        System.out.println(result);
    }
}
